<?php
    
    $uri = str_replace("shop-thoitrang/", "", $_SERVER['REQUEST_URI']);
    $uri = str_replace(".html", "", $uri);
    $tmp_uri = explode("/", $uri);

    $tieude_id = $tmp_uri[2];
    $arr = explode("-", $tieude_id);        
     $IDLT = (int) end($arr);
    $layidTLtuLoai=$tc->getIDTLTuIDLoai($IDLT);
    $row_layidTLtuLoai=  mysql_fetch_assoc($layidTLtuLoai);  
    /*$link = "danhmuc/"?><?php echo $row_layidTLtuLoai['ten_kd']; ?>-<?php echo $row_layidTLtuLoai['loai_id'].".html"; */
    $link1=  str_replace("/shop-thoitrang/", "", $_SERVER['REQUEST_URI']);
    $uri1=explode("?","$link1");
    $link = $uri1[0];
?>
<div id="container-wrapper">
    <div id="container">
        <div id="scroll-down-target"></div> <!-- This is Flexslider scroll down button target -->


        <!-- Begin notifications -->
        <div id="notification-fixed">
            <div id="notification"></div>
        </div>       
        <script type="text/javascript">
            $(function() {
            $('.success .close, .warning .close, .attention .close, .information .close').live('click', function (event) {
            event.preventDefault();
                    $('#notification').removeClass('active');
            });
            });        </script>
        <!-- End cart "Close" button mobile devices fix script -->



        <div id="column-right">
            <div id="box-category-area">
                <div class="box">
                    <div class="box-heading"><span class="category">Danh mục sản phẩm</span></div>
                    <div class="box-content">
                        <ul class="box-category">
                            <?php
                            
                                $IDTLtuIDLT=$row_layidTLtuLoai['idTL'];
                                $tl=$tc->getTheLoai();
                                while ($row_tl=  mysql_fetch_assoc($tl)){
                            ?>
                            <li>
                                <!-- Begin category links -->
                                <a class="<?php echo $idTL=$row_tl['idTL']; if($idTL==$IDTLtuIDLT) echo " active"; ?>" href="" id="<?php $row_tl['idTL'];?>" ><?php echo $row_tl['TenTL']; ?></a>
                                <!-- End category links -->

                                <!-- Begin sub category links -->
                                <ul>
                                    <?php 
                                        $idTL=$row_tl['idTL'];
                                        $loaisp=$tc->getLoaiSPTheoTheLoai($idTL);
                                        while ($row_loai=  mysql_fetch_assoc($loaisp)){
                                    ?>
                                    <li>
                                        <a class="<?php echo $idLT=$row_loai['loai_id']; if($idLT==$IDLT) echo " active"; ?>" href="danhmuc/<?php echo $row_loai['ten_kd'].'-'.$row_loai['idTL']; ?>.html"><?php echo $row_loai['loai']; ?></a>
                                    </li>
                                     <?php } ?>
                                </ul>
                                <!-- End sub category links -->
                            </li>
                              <?php } ?>
                            
                            
                        </ul>
                    </div>
                </div>
            </div>    
            <?php /*<div class="box">
                <div class="box-heading"><span class="featured">Mua nhiều</span></div>
                <div class="carousel-box-content">
                    <div id="carousel300">
                        <div class=" jcarousel-skin-opencartfc"><div class="jcarousel-container jcarousel-container-horizontal" style="position: relative; display: block;"><div class="jcarousel-clip jcarousel-clip-horizontal" style="position: relative;"><ul class="jcarousel-list jcarousel-list-horizontal" style="overflow: hidden; position: relative; top: 0px; margin: 0px; padding: 0px; left: -1935px; width: 2150px;">
                                        
                                        <?php
                                           // $sp_muanhieu=$tc->sanpham_muanhieu();
                                           // while($row_spmuanhieu=  mysql_fetch_assoc($sp_muanhieu)){
                                        
                                        ?>
                                        <li class="jcarousel-item jcarousel-item-horizontal jcarousel-item-1 jcarousel-item-1-horizontal" jcarouselindex="1" style="float: left; list-style: none; width: 215px;">

                                            <div class="box-product">
                                                <!-- Begin box-product div -->
                                                <div>
                                                    <!-- Begin boxgrid -->
                                                    <div class="boxgrid">
                                                        <div class="image"><a href="49"><img width="215" height="215" src="<?php echo $row_spmuanhieu['hinh_dai_dien']; ?>" alt="Samsung Galaxy Tab"></a></div>
                                                        <!-- Begin box-product-info -->
                                                        <div class="box-product-info">
                                                            <div class="thumbnail-buttons">
                                                                <div class="more"><a href="49" oldtitle="View More" title=""></a></div>
                                                                <div class="cart"><input type="button" value="Add to Cart" onclick="addToCart( & #39; 49 & #39; );" class="button-cart" oldtitle="Add to Cart" title=""></div>
                                                                
                                                            </div>
                                                        </div>
                                                        <!-- End box-product-info -->
                                                    </div>
                                                    <!-- End boxgrid -->

                                                    <!-- Begin boxgrid-bottom -->
                                                    <div class="boxgrid-bottom">
                                                        <div class="arrow-box"></div>
                                                        <div class="name"><a href="sanpham/<?php echo $row_spmuanhieu['ten_sp_kd']?>-<?php echo $row_spmuanhieu['sp_id']; ?>.html"><?php echo $row_spmuanhieu['ten_sp']; ?></a></div>
                                                        <div class="price">
                                                            <?php echo number_format($row_spmuanhieu['gia'].' VNĐ'); ?>						          								        	</div>

                                                    </div>
                                                    <!-- End boxgrid-bottom -->
                                                </div>
                                                <!-- End box-product div -->
                                            </div>

                                        </li>
                                            <?php// } ?> 
                                        
                                        
                                    </ul></div><div class="jcarousel-prev jcarousel-prev-horizontal" style="display: block;"></div><div class="jcarousel-next jcarousel-next-horizontal jcarousel-next-disabled jcarousel-next-disabled-horizontal" disabled="disabled" style="display: block;"></div></div></div>
                    </div>
                </div>
            </div>
            */?>

            <script type="text/javascript"><!--
            function mycarousel_initCallback(carousel)
                        {
                        // Disable autoscrolling if the user clicks the prev or next button.
                        carousel.buttonNext.bind('click', function() {
                        carousel.startAuto(0);
                        });
                                carousel.buttonPrev.bind('click', function() {
                                carousel.startAuto(0);
                                });
                                // Pause autoscrolling if the user moves with the cursor over the clip.
                                carousel.clip.hover(function() {
                                carousel.stopAuto();
                                }, function() {
                                carousel.startAuto();
                                });
                        };
                        $('#carousel300 ul').jcarousel({
                initCallback: mycarousel_initCallback,
                        animation: 300,
                        vertical: false,
                        easing: "easeInOutQuad",
                        auto:  1,
                        visible: 1,
                        scroll: 1});//--></script>


            <div class="box">
                <div id="filter-box-heading" class="box-heading"><span class="filter">Tìm theo</span></div>
                <div class="box-content">
                    <div id="box-filter">
                        <ul class="box-filter-inner">
                            <li><span id="filter-group1">Màu sắc</span>
                                <ul>
                                    <?php
                                        $list_mau = $tc->getListMau();
                                        while ($row_m = mysql_fetch_assoc($list_mau)) {
                                        $chitiet_m = $tc->getDetailMau($row_m['mau_id']);
                                        $row_mau = mysql_fetch_assoc($chitiet_m);
                                    ?>
                                    <li>
                                        <input type="checkbox" value="<?php echo $row_mau['mau_id'];?>" id="filter3">
                                        <label for="filter3"><?php echo $row_mau['ten'];?></label>
                                    </li>
                                    <?php } ?>
                                </ul>
                            </li>
                            <li><span id="filter-group2">Khoảng giá</span>
                                <ul>
                                    <?php 
                                        $khoanggia = $modelKieu->getListKhoangGia();
                                        while ($row = mysql_fetch_assoc($khoanggia)) {
                                    ?>
                                    <li>
                                        <input type="checkbox" value="<?php echo $row['kg_id'];?>" id="filter4">
                                        <label for="filter4"><?php echo number_format($row['giatu']);?>-<?php echo number_format($row['giaden'])." VNĐ"; ?></label>
                                    </li>
                                        <?php } ?>
                                </ul>
                            </li>
                        </ul>
                        <a id="button-filter" class="button">Tìm</a> 
                    </div>
                </div>
            </div>

            <script type="text/javascript"><!--
                        $('#button-filter').bind('click', function() {
                filter = [];
                        $('.box-filter-inner input[type=\'checkbox\']:checked').each(function(element) {
                filter.push(this.value);
                });
                        location = '&filter=' + filter.join(',');
                });//--></script> 
            <div class="box">
                <div class="box-heading"><span class="specials">Giảm giá</span></div>
                <div class="box-content">
                    <div class="box-product">

                        <?php
                            $sp_khuyenmai=$modelSanPham->List_SPKhuyenMai();
                            while ($row_spkm=  mysql_fetch_assoc($sp_khuyenmai)){
                        ?>
                        <!-- Begin box-product div -->
                        <div>

                            <!-- Begin boxgrid -->
                            <div class="boxgrid">
                                <div class="image"><a href="sanpham/<?php echo $row_spkm['ten_sp_kd']?>-<?php echo $row_spkm['sp_id']; ?>.html"><img width="65" height="65" src="<?php echo $row_spkm['hinh_dai_dien']; ?>" alt=""></a></div>
                                <!-- Begin box-product-info -->
                                <div class="box-product-info">
                                    <div class="thumbnail-buttons">
                                        <div class="more"><a href="sanpham/<?php echo $row_spkm['ten_sp_kd']?>-<?php echo $row_spkm['sp_id']; ?>.html" oldtitle="View More" title=""></a></div>
                                        <div class="cart"><input type="button" value="Add to Cart" onclick="addToCart( & #39; 42 & #39; );" class="button-cart" oldtitle="Add to Cart" title=""></div>
                                        
                                    </div>
                                </div>
                                <!-- End box-product-info -->
                            </div>
                            <!-- End boxgrid -->

                            <!-- Begin boxgrid-bottom -->
                            <div class="boxgrid-bottom">
                                <div class="arrow-box"></div>
                                <div class="name"><a href="sanpham/<?php echo $row_spkm['ten_sp_kd']?>-<?php echo $row_spkm['sp_id']; ?>.html"><?php echo $row_spkm['ten_sp']; ?>"</a></div>
                                <div class="price">
                                    <span class="price-old"><?php echo number_format($row_spkm['gia'].' VNĐ'); ?></span>
                                    <span class="price-new">
                                        <?php 
                                           $giacu=$row_spkm['gia'];
                                           $khuyenmai=$row_spkm['khuyen_mai'];
                                           echo number_format($giamoi=$giacu-($giacu*$khuyenmai/100));
                                       ?>                                       
                                    </span>
                                    <div class="ribbon-sale">Giãm<?php echo $khuyenmai=$row_spkm['khuyen_mai'].'%'; ?></div>
                                </div>
                            </div>
                            <!-- End boxgrid-bottom -->

                        </div>
                        <?php } ?>

                        

                    </div>
                </div>
            </div>  <?php /*  <div class="box">
                <div class="box-heading"><span class="bestsellers">Mua Nhiều</span></div>
                <div class="box-content">
                    <div class="box-product">

                        <!-- Begin box-product div -->
                        <div>

                            <!-- Begin boxgrid -->
                            <div class="boxgrid">
                                <div class="image"><a href="48"><img style="width: 65px;" src="static/g-207x207.jpg" alt="iPod Classic"></a></div>
                                <!-- Begin box-product-info -->
                                <div class="box-product-info">
                                    <div class="thumbnail-buttons">
                                        <div class="more"><a href="48" oldtitle="View More" title=""></a></div>
                                        <div class="cart"><input type="button" value="Add to Cart" onclick="addToCart( & #39; 48 & #39; );" class="button-cart" oldtitle="Add to Cart" title=""></div>
                                        <div class="wishlist"><a onclick="addToWishList( & #39; 48 & #39; );" oldtitle="Add to Wish List" title=""></a></div>
                                        <div class="compare"><a onclick="addToCompare( & #39; 48 & #39; );" oldtitle="Add to Compare" title=""></a></div>
                                    </div>
                                </div>
                                <!-- End box-product-info -->
                            </div>
                            <!-- End boxgrid -->

                            <!-- Begin boxgrid-bottom -->
                            <div class="boxgrid-bottom">
                                <div class="arrow-box"></div>
                                <div class="name"><a href="48">iPod Classic</a></div>
                                <div class="price">
                                    $119.50          		        	</div>

                            </div>
                            <!-- End boxgrid-bottom -->

                        </div>
                      
                    </div>
                </div>
            </div>    --> */ ?>

            


            <!-- Begin scroll down button script -->
            <script type="text/javascript">
                        jQuery(document).ready(function(){
                var catTopPosition = jQuery('#scroll-down-target').offset().top;
                        // When #scroll-down is clicked
                        jQuery('#full-width-slider .scroll-down').click(function(){
                // Scroll down to '#container'
                jQuery('html, body').animate({scrollTop:catTopPosition}, 'slow');
                        // Stop the link from acting like a normal anchor link
                        return false;
                });
                });            </script>
            <!-- End scroll down button script -->  </div>

        <!-- Begin content -->
        <div id="content">

            <!-- Begin breadcrumb -->
            <div id="breadcrumb-center" class="breadcrumb">
                <a href="index.php">Trang chủ</a>
                » <a href=""><?php echo $row_layidTLtuLoai['TenTL']; ?></a>
                » <a href=""><?php echo $row_cat['loai']; ?></a>
            </div>
            <!-- End breadcrumb -->

            
            

            


            <script type="text/javascript">
                        $(window).load(function() {
                $('#flexslideshow1').flexslider({
                slideshow: true, // Setup a slideshow for the slider to animate automatically (true or false).
                        animation: "fade", // Controls the animation type (changeable through admin panel).
                        pauseOnHover: true, // Pause the slideshow when hovering over slider, then resume when no longer hovering (true or false).
                        pauseOnAction: true, // Pause the slideshow when interacting with control elements (true or false).
                        touch: true, // Allow touch swipe navigation of the slider on enabled devices (true or false).
                        animationSpeed: 600, // Set the speed of animations, in milliseconds.
                        slideshowSpeed: 6500, // Set the speed of the slideshow cycling, in milliseconds.
                        smoothHeight: false, // Animate the height of the slider smoothly for slides of varying image height (true or false).
                        controlNav: true, // Create navigation for paging control of each slide (true or false).
                        directionNav: true, // Create previous/next arrow navigation (true or false).
                        direction: "horizontal", // Controls the animation direction ("horizontal" or "vertical").
                        useCSS: false // Fixes black screen issue on Saffari (do not change this!!!).
                });
                });            </script>


            <!-- Begin scroll down button script -->
            <script type="text/javascript">
                        jQuery(document).ready(function(){
                var catTopPosition = jQuery('#scroll-down-target').offset().top;
                        // When #scroll-down is clicked
                        jQuery('#full-width-slider .scroll-down').click(function(){
                // Scroll down to '#container'
                jQuery('html, body').animate({scrollTop:catTopPosition}, 'slow');
                        // Stop the link from acting like a normal anchor link
                        return false;
                });
                });            </script>
            <!-- End scroll down button script -->            
            <div class="category-info">
                <div class="category-info-inner">
                <div class="heading-center"><?php echo $row_cat['title'] ;?></div>
                                               
                                </div>
            </div>
            <!-- Begin product filter -->
            <div class="product-filter">                
                
                <div class="sort">Sắp sếp:      <select onchange="location = this.value;">
                        <option value="#" selected="selected">Default</option>
                        <option value="#">Tên (A - Z)</option>
                        <option value="#">Tên (Z - A)</option>
                        <option value="#">Giá (Thấp -> Cao)</option>
                        <option value="#">Giá (Cao -> Thấp</option>
                       
                    </select>
                </div>
            </div>
            <!-- End product filter -->

            <!-- Begin product list -->
            <div class="box">
                <div class="box-content">
                   
                    <div class="box-product">
                       
                        <!-- Begin box-product div -->
                         <?php 
                        //echo $idTL=$_GET['idTL']; die;
                         $idLoai=$row_cat["loai_id"];
                         $page_show = 5;

                        $limit = 8;

                        $trangs = $modelSanPham->SanPham_List_TheoLoai($idLoai, -1, -1);

                        $total_record = mysql_num_rows($trangs);

                        $total_page = ceil($total_record / $limit);

                        if (isset($_GET['page']) == false) {
                            $page = 1;
                        } else {
                            $page = (int) $_GET['page'];       
                        }

                         $offset = $limit * ($page - 1);
                         
                        $listsp = $modelSanPham->SanPham_List_TheoLoai( $idLoai,$tukhoa,$offset, $limit);
                        
                        $i = ($page-1)*$limit;
                        while ($row_list = mysql_fetch_assoc($listsp)) {                       
                        $i++;
                            $giacu=$row_list['gia'];
                            $khuyenmai=$row_list['khuyen_mai'];
                             $gia=number_format($giamoi=$giacu-($giacu*$khuyenmai/100)).' VNĐ';
                             
                        ?>
                        <div>
                            <!-- Begin boxgrid -->
                            <div class="boxgrid">
                                <div class="image"><a href="sanpham/<?php echo $row_list['ten_sp_kd']?>-<?php echo $row_list['sp_id']; ?>.html"><img width="207" height="207" src="<?php echo $row_list['hinh_dai_dien']; ?>" ></a></div>
                                <!-- Begin box-product-info -->
                                <div class="box-product-info">
                                    <div class="thumbnail-buttons">
                                        <div class="more"><a class="fancybox" href="<?php echo $row_list['hinh_dai_dien']; ?>" title="<?php echo $row_list['ten_sp']; ?>"></a></div>
                                        <div class="cart"><a href="sanpham/<?php echo $row_list['ten_sp_kd'] ?>-<?php echo $row_list['sp_id']; ?>.html" title="Mua liền"><input type="button"  class="button-cart"  title="Mua liền"></a></div>
                                        
                                    </div>
                                </div>
                                <!-- End box-product-info -->
                            </div>
                            <!-- End boxgrid -->

                            <!-- Begin boxgrid-bottom -->
                            <div class="boxgrid-bottom">
                                <div class="arrow-box"></div>
                                <div class="name"><a href="sanpham/<?php echo $row_list['ten_sp_kd']?>-<?php echo $row_list['sp_id']; ?>.html"><?php echo $row_list['ten_sp']; ?></a></div>
                                <div class="price">
                                    <?php 
                                            $khuyenmai=$row_list['khuyen_mai'];
                                            if($khuyenmai == 0){
                                                echo number_format($row_list['gia']).' VNĐ';
                                            }else echo ' <span class="price-old">'.number_format ($row_list['gia']).'</span> <span class="price-new">'.$gia.'</span>
                                        <div class="ribbon-sale"></div>';
                                    ?>
                                </div>

                            </div>
                            <!-- End boxgrid-bottom -->
                        </div>
                        <?php  } ?>
                        <div>
                            <?php
                                
                                echo $modelSanPham->phantrang($page, $page_show, $total_page, $link); 
                            ?>
                        </div>
                    </div>
                    
                </div>
            </div>
            

            <!-- Begin no pagination -->
            
            <!-- End no pagination -->

            <div class="box">
                <div class="box-heading"><span class="latest">Sản phẩm mới</span></div>
                <div class="carousel-box-content">
                    <div id="carousel200">
                        <div class=" jcarousel-skin-opencartfc"><div class="jcarousel-container jcarousel-container-horizontal" style="position: relative; display: block;"><div class="jcarousel-clip jcarousel-clip-horizontal" style="position: relative;"><ul class="jcarousel-list jcarousel-list-horizontal" style="overflow: hidden; position: relative; top: 0px; margin: 0px; padding: 0px; left: -1344px; width: 2240px;">
                                         <?php                                             
                                            $listspmoi=$tc ->sanphammoi();
                                            while($row_spmoi=  mysql_fetch_assoc($listspmoi)){
                                              $giacu=$row_spmoi['gia'];
                                            $khuyenmai=$row_spmoi['khuyen_mai'];
                                            $gia=number_format($giamoi=$giacu-($giacu*$khuyenmai/100)).' VNĐ';
                                         ?>
                                        <li class="jcarousel-item jcarousel-item-horizontal jcarousel-item-1 jcarousel-item-1-horizontal" jcarouselindex="1" style="float: left; list-style: none; width: 224px;">

                                            <div class="box-product">
                                                <!-- Begin box-product div -->
                                                <div>
                                                    <!-- Begin boxgrid -->
                                                    <div class="boxgrid">
                                                        <div class="image"><a href="sanpham/<?php echo $row_spmoi['ten_sp_kd']?>-<?php echo $row_spmoi['sp_id']; ?>.html"><img width="215" height="215" src="<?php echo $row_spmoi['hinh_dai_dien']; ?>" alt="Samsung Galaxy Tab"></a></div>
                                                        <!-- Begin box-product-info -->
                                                        <div class="box-product-info">
                                                            <div class="thumbnail-buttons">
                                                                <div class="more"><a href="49" oldtitle="View More" title=""></a></div>
                                                                <div class="cart"><input type="button" value="Add to Cart" onclick="addToCart( & #39; 49 & #39; );" class="button-cart" oldtitle="Add to Cart" title=""></div>
                                                                
                                                            </div>
                                                        </div>
                                                        <!-- End box-product-info -->
                                                    </div>
                                                    <!-- End boxgrid -->

                                                    <!-- Begin boxgrid-bottom -->
                                                    <div class="boxgrid-bottom">
                                                        <div class="arrow-box"></div>
                                                        <div class="name"><a href="sanpham/<?php echo $row_spmoi['ten_sp_kd']?>-<?php echo $row_spmoi['sp_id']; ?>.html"><?php echo $row_spmoi['ten_sp']; ?></a></div>
                                                        <div class="price">
                                                           <?php 
                                                                $khuyenmai=$row_spmoi['khuyen_mai'];
                                                                if($khuyenmai == 0){
                                                                    echo number_format($row_spmoi['gia']).' VND';
                                                                }else echo ' <span class="price-old">'.number_format ($row_spmoi['gia']).'</span> <span class="price-new">'.$gia.'</span>
                                                            <div class="ribbon-sale"></div>';
                                                           ?>
                                                        </div>

                                                    </div>
                                                    <!-- End boxgrid-bottom -->
                                                </div>
                                                <!-- End box-product div -->
                                            </div>

                                        </li>
                                            <?php } ?>
                                        
                                    </ul></div><div class="jcarousel-prev jcarousel-prev-horizontal" style="display: block;"></div><div class="jcarousel-next jcarousel-next-horizontal jcarousel-next-disabled jcarousel-next-disabled-horizontal" disabled="disabled" style="display: block;"></div></div></div>
                    </div>
                </div>
            </div>


            <script type="text/javascript"><!--
            function mycarousel_initCallback(carousel)
                        {
                        // Disable autoscrolling if the user clicks the prev or next button.
                        carousel.buttonNext.bind('click', function() {
                        carousel.startAuto(0);
                        });
                                carousel.buttonPrev.bind('click', function() {
                                carousel.startAuto(0);
                                });
                                // Pause autoscrolling if the user moves with the cursor over the clip.
                                carousel.clip.hover(function() {
                                carousel.stopAuto();
                                }, function() {
                                carousel.startAuto();
                                });
                        };
                        $('#carousel200 ul').jcarousel({
                initCallback: mycarousel_initCallback,
                        animation: 300,
                        vertical: false,
                        easing: "easeInOutQuad",
                        wrap: 'both',
                        auto:  1,
                        visible: 4,
                        scroll: 1});
//--></script>
        </div>
        <!-- End content -->

    </div><!-- End container //-->
</div><!-- End container wrapper //-->